package cn.cau.service.impl;

import cn.cau.dao.CodeManageDao;
import cn.cau.dao.CodeNumberDao;
import cn.cau.dao.CodeRuleDao;
import cn.cau.entity.CodeManageRecord;
import cn.cau.entity.CodeRule;
import cn.cau.service.CodeManageChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CodeManageChangeServiceImpl implements CodeManageChangeService {
    @Autowired
    CodeManageDao codeManageDao;
    @Autowired
    CodeNumberDao codeNumberDao;
    @Autowired
    private CodeRuleDao codeRuleDao;
    @Override
    public int submitCodeRuleChange(CodeManageRecord codeManageRecord){
        return codeManageDao.insertManageApplication(codeManageRecord);
    };
    @Override
    public boolean isCodeRuleHaveCodeNumber(int codeRuleId){
        return codeNumberDao.findRecordsByCodeRuleId(codeRuleId).size() != 0;
    }
    @Override
    public List<CodeRule> showCodeRuleChangeList(int userId){
        return codeRuleDao.findLiveCodeRuleByuserId(userId);
    }
    @Override
    public CodeManageRecord findRecordByNewCodeRuleId(int codeRuleId){
        return codeManageDao.findRecordByNewCodeRuleId(codeRuleId);
    }
}
